import { IPSDEGrid } from '../../control/grid/ipsdegrid';
import { IPSDEGridEditItem } from '../../control/grid/ipsdegrid-edit-item';
import { IPSModelObject } from '../../ipsmodel-object';
import { PSModelServiceProxyImpl } from '../../psmodel-service-proxy-impl';

/**
 * 全局默认通用代理
 *
 * @author chitanda
 * @date 2021-07-02 14:07:43
 * @export
 * @class PSDEGridColumnServiceProxy
 * @extends {PSModelServiceProxyImpl}
 */
export class PSDEGridColumnServiceProxy extends PSModelServiceProxyImpl {
  getPSModel4(
    relatedPSModelObject: IPSModelObject,
    cls: string,
    objNode: any,
    strTag: string,
  ): IPSModelObject {
    switch (strTag) {
      case 'getPSDEGridEditItemUpdate':
        return this.getPSDEGridEditItemUpdate(
          relatedPSModelObject as IPSDEGridEditItem,
          objNode,
        );
    }
    return this.getRealPSModelService().getPSModel4(
      relatedPSModelObject,
      cls,
      objNode,
      strTag,
    );
  }

  getPSDEGridEditItemUpdate(
    relatedPSModelObject: IPSDEGridEditItem,
    obj: any,
  ): any {
    if (obj.modelref === true) {
      const model = this.getParentPSModelObject(
        relatedPSModelObject,
        'control.grid.IPSDEGrid',
      ) as IPSDEGrid;
      if (model) {
        return model.findPSDEGridEditItemUpdate(obj);
      }
    }
    return null;
  }
}
